Skip to content

Fix func command usage format and conditionally display [subcontext] placeholder#4562

Merged
surgupta-msft merged 4 commits intomainfrom
copilot/fix-4561
Aug 1, 2025
Merged

Fix func command usage format and conditionally display [subcontext] placeholder#4562
surgupta-msft merged 4 commits intomainfrom
copilot/fix-4561

Conversation

Copy link
Contributor

Copilot AI commented Jul 31, 2025

The func command help output was showing an incorrect usage format with duplicate [context] placeholders and displaying [subcontext] even for contexts that don't have any subcontexts, which was confusing for users.

Problem

The help system had two issues:

  1. Duplicate placeholders: General help showed func [context] [context] <action> suggesting users could provide two context parameters
  2. Misleading subcontext display: All contexts showed [subcontext] even when they had no subcontexts (e.g., kubernetes)

For example:

> func kubernetes
Usage: func kubernetes [subcontext] <action> [-/--options]

But kubernetes has no subcontexts, making this confusing.

Solution

Fixed usage format strings in HelpAction.cs:

  1. General Help: Changed from func [context] [context] <action> to func [context] <action>
  2. Context Help: Now conditionally shows [subcontext] only when the context actually has subcontexts

Examples

Before:

  • General: Usage: func [context] [context] <action> [-/--options]
  • Azure: Usage: func azure [subcontext] <action> [-/--options]
  • Kubernetes: Usage: func kubernetes [subcontext] <action> [-/--options]

After:

  • General: Usage: func [context] <action> [-/--options]
  • Azure: Usage: func azure [subcontext] <action> [-/--options] ✓ (has subcontexts)
  • Kubernetes: Usage: func kubernetes <action> [-/--options] ✓ (no subcontexts)

The fix ensures the usage format accurately reflects the actual command structure and only shows placeholders when they're actually applicable.

Fixes #4561.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…bcontext display

Co-authored-by: surgupta-msft <16623184+surgupta-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] [Bug] Fix the func command usage format Fix func command usage format to remove duplicate [context] placeholder Jul 31, 2025
Copilot AI requested a review from surgupta-msft July 31, 2025 22:47
@liliankasem
Copy link
Member

Validated the following:

> func

Usage: func [context] <action> [-/--options]

Contexts:
> func azure

Usage: func azure [subcontext] <action> [-/--options]

Contexts:
functionapp  Commands for working with a local functions project
storage      Commands to work with Azure Storage
> func azure functionapp

Usage: func azure functionapp <action> [-/--options]

Actions: 
> func kubernetes

Usage: func kubernetes [subcontext] <action> [-/--options]

Actions: 

Kubernetes for example does not have have a subcontext, is it possible to display "subcontext" when we know the context has subcontext?

…exts exist

Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 31, 2025

Validated the following:

...

Yes, absolutely! I've implemented exactly that change. The help display now conditionally shows [subcontext] only when the context actually has subcontexts available.

Changes made in commit 7a674fa:

  • For contexts with subcontexts (like azure): Shows Usage: func azure [subcontext] <action> [-/--options]
  • For contexts without subcontexts (like kubernetes): Shows Usage: func kubernetes <action> [-/--options]

The code now checks if any subcontexts exist using the existing contexts.Any() logic before deciding whether to include [subcontext] in the usage format. This makes the help output more accurate and less confusing for users.

Copilot AI changed the title Fix func command usage format to remove duplicate [context] placeholder Fix func command usage format and conditionally display [subcontext] placeholder Jul 31, 2025
Copilot AI requested a review from liliankasem July 31, 2025 23:16
@liliankasem liliankasem marked this pull request as ready for review July 31, 2025 23:25
@liliankasem liliankasem requested a review from a team as a code owner July 31, 2025 23:25
@surgupta-msft surgupta-msft merged commit 31f142e into main Aug 1, 2025
33 checks passed
@surgupta-msft surgupta-msft deleted the copilot/fix-4561 branch August 1, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Fix the func command usage format

4 participants